package com.dx.VegetableOxygenBarBackEnd.once;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.dx.VegetableOxygenBarBackEnd.model.domain.entity.User;
import com.dx.VegetableOxygenBarBackEnd.service.UserService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

@Component
public class InsertUsers {
    @Resource
    private UserService userService;

//    @Scheduled( )
    public void doInsertUsers(){
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        final int INSERT_NUM = 1000;
        List<User> userList = new ArrayList<>();
        for (int i = 0 ;i<INSERT_NUM;i++){
            User user = new User();
            user.setUserName("fakeUser");
            user.setProfile("假用户");
            user.setUserAccount("fakeUsers");
            user.setAvatarUrl("http://www.baidu.com");
            user.setUserPassword("12345667");
            user.setGender(0);
            user.setPhone("123");
            user.setEmail("123@qwe.com");
            user.setUserStatus(0);
            user.setIsDelete(0);
            user.setUserRole(0);
            user.setTags("[]");
            userList.add(user);
        }
        userService.saveBatch(userList);
        stopWatch.stop();
        System.out.println(stopWatch.getTotalTimeMillis());
    }
}
